package object.homework;

import java.util.Arrays;

/**
 * split()：拆分，将当前字符串按照满足正则表达式的部分进行拆分，将拆分出的以String[]形式返回
 *
 * String[] split(String regex)
 * 将当前字符串中满足正则表达式(regex)的部分进行拆分，将拆分出的以String[]形式返回
 */
public class SplitDemo {
    public static void main(String[] args) {
        String line = "abc123def456ghi";
        String[] arr = line.split("[0-9]+");
        System.out.println(Arrays.toString(arr));//数组转换为字符串并输出:[abc, def, ghi]

        line = "=123=456==78=====";
        arr = line.split("=");
        line = Arrays.toString(arr);
        System.out.println(line);//[, 123, 456, , 78]
        System.out.println(arr.length);//5
    }
}
